-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
advanced interpret usage #762
advanced interpret usage #762
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@tomicapretto the code diff looks large. Part of that is because I moved all data generating functions that were in |
@GStechschulte, I wrote a comment in the previous issue #751 to better relate to our earlier question regarding the HDI. |
I replied to your question regarding the HDI in #751. Thanks for the feedback! |
1865b92
to
ebb1ab0
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #762 +/- ##
==========================================
- Coverage 89.93% 89.64% -0.29%
==========================================
Files 45 46 +1
Lines 3784 3797 +13
==========================================
+ Hits 3403 3404 +1
- Misses 381 393 +12 ☔ View full report in Codecov by Sentry. |
@GStechschulte the new notebook is amazing, thanks a lot! |
Thanks! And also thanks for the review. Much appreciated! 👍🏼 Edit: the new docs notebook doesn't have a thumbnail. Do you see an issue with this other than an inconsistency with the other example notebooks? |
aaf8c95
to
ca8682d
Compare
It's all good, we can add one later. Thanks!! |
This PR addresses issue #751 and #703
In #751 a user may want to compute complex comparisons or slopes that is not supported. Instead of adding more kwargs to handle each case, we add two functions
data_grid
, andselect_draws
that allow the user to compute complex quantities of interest.data_grid
allows the user to create their own pairwise grid (returned as a dataframe) which can then be passed tomodel.predict
. Since the predict method returns the inference data, this simultaneously resolves #703.Talking with @tomicapretto, we decide to not include a kwarg
return_idata
tocomparisons
,predictions
, andslopes
because if the user wants the inference data to compute their own quantities of interest, then they are only using the interpret module for its "data generating" capability, i.e., the data grid. Additionally, the user does not need to usedata_grid
, they can create their data however they deem fit, and pass it the predict method.select_draws
is a helper function that selects the posterior or posterior predictive draws from the InferenceData object returned bymodel.predict
given a conditional dictionary. The conditional dictionary represents the values that correspond to that draw—this is essential in computing comparisons and slopes.Below, we use the new
data_grid
to create a pairwise dataframe (cross-join) that will be the data for computing comparisons.Use this data in
model.predict
and then use the newselect_draws
function that selects the draws based on the conditional dictionary{"livebait": ...}
."count_mean"
is the data variable we are selecting in the posterior group of the inference data. This returns the draws that satisfy the condition. Lastly, comparisons are computed.This result above is the same as the
estimate
column below:For a more advanced demo that computes cross-comparisons, see the advanced interpret usage docs (still a work in progress).
This is still a work in progress, so feedback is welcome. Don't dive too deep in a code review just yet. @tomicapretto @jt-lab @AylinH @zwelitunyiswa
To do: